package com.iot08.admin.service.page;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.io.Serializable;
import java.util.Optional;

/**
 * @version 1.0
 * @author: Rock
 * @Description: 分页
 * @time: 2020/8/14 9:12
 */
public class PageableImpl implements Serializable, Pageable {

    private static final long serialVersionUID = 1L;

    private PageVO page;

    public PageVO getPage() {
        return page;
    }

    public void setPage(PageVO page) {
        this.page = page;
    }

    @Override
    public boolean isPaged() {
        return false;
    }

    @Override
    public boolean isUnpaged() {
        return false;
    }

    @Override
    public int getPageNumber() {
        return page.getCurrentPage();
    }

    @Override
    public int getPageSize() {
        return page.getShowCount();
    }

    @Override
    public long getOffset() {
        return (page.getCurrentPage() - 1) * page.getShowCount();
    }


    @Override
    public Sort getSort() {
        return page.getSort();
    }

    @Override
    public Sort getSortOr(Sort sort) {
        return null;
    }

    @Override
    public Pageable next() {
        return null;
    }

    @Override
    public Pageable previousOrFirst() {
        return null;
    }

    @Override
    public Pageable first() {
        return null;
    }

    @Override
    public boolean hasPrevious() {
        return false;
    }

    @Override
    public Optional<Pageable> toOptional() {
        return Optional.empty();
    }
}